//package top.cluski.shardingsphere.algorithm;
//
//import com.google.common.collect.Range;
//import org.apache.shardingsphere.api.sharding.complex.ComplexKeysShardingAlgorithm;
//import org.apache.shardingsphere.api.sharding.complex.ComplexKeysShardingValue;
//
//import java.math.BigInteger;
//import java.util.ArrayList;
//import java.util.Collection;
//
//public class MyComplexTableShardingAlgorithm implements ComplexKeysShardingAlgorithm<Long> {
//
//    // select * from course cid between xxx and xxx and user_id = 1007L
//    @Override
//    public Collection<String> doSharding(Collection<String> collection, ComplexKeysShardingValue<Long> complexKeysShardingValue) {
//        Range<Long> cidRange = complexKeysShardingValue.getColumnNameAndRangeValuesMap().get("cid");
//        Collection<Long> userIdCol = complexKeysShardingValue.getColumnNameAndShardingValuesMap().get("user_id");
//
//        Long cidUpper = cidRange.upperEndpoint();
//        Long cidLower = cidRange.lowerEndpoint();
//
//        ArrayList<String> result = new ArrayList<>();
//
//        for (Long userId : userIdCol) {
//            BigInteger userIdB = BigInteger.valueOf(userId);
//            BigInteger target = (userIdB.mod(new BigInteger("2"))).add(new BigInteger("1"));
//            result.add(complexKeysShardingValue.getLogicTableName() + "_" + target);
//        }
//        return result;
//    }
//}
